package cn.sycoder.dto;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@ApiModel(value = "Product对象", description = "")
public class ProductFileDto implements Serializable {

    @Excel(name = "产品名称")
    @ApiModelProperty("产品名称")
    private String name;

    @Excel(name = "产品编号")
    @ApiModelProperty("产品编号")
    private String code;

    @Excel(name = "库存数量")
    @ApiModelProperty("库存值")
    private Integer inventory;

    @Excel(name = "单位")
    @ApiModelProperty("单位")
    private String unit;

    @Excel(name = "型号")
    @ApiModelProperty("型号")
    private String type;

    @Excel(name = "库房地址")
    @ApiModelProperty("库房地址")
    private String storeHouse;

    @Excel(name = "具体位置")
    @ApiModelProperty("具体位置")
    private String site;

    @ApiModelProperty("库房地址多个存储用 ，号隔开如： 库房，位置，位置编号")
    @Excel(name = "产品位置")
    private String location;

    public void setLocation(String location){
        if (!StringUtils.isEmpty(location)){
            String[] split = location.split(",");
            String storeHouse = split[0]; // 获取逗号分割后左边的值
            this.storeHouse = storeHouse;
            String site = split[1]; // 获取逗号分割后右边的值
            this.site = site;
        }
        this.location = location;
    }
}
